<template>
	<view>
		<view class="uni-padding-wrap uni-common-mt">
			<view class="button-sp-area">
				<!-- #ifdef MP-WEIXIN -->
					<button type="primary" plain="true" @click="wechatLogin()">微信登录</button>
				<!-- #endif -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			};
		},
		methods:{
			// #ifdef MP-WEIXIN
			wechatLogin(){
				const net = this.$net;
				uni.login({
				  provider: 'weixin',
				  success: function (loginRes) {
					const entity = {
						code: loginRes.code
					}
					net.login(entity).then(res => {
						// console.log(res.data.openId);
						uni.setStorage({
							key:"user",
							data:res.data.openId,
							success() {
								uni.reLaunch({ 
									url:`/pages/index/index`
								})
							}
						})
					});
				  },
				  fail() {
				  	this.$api.msg("登录失败，请检查网络");
				  }
				});
			},
			// #endif
		}
	}
</script>

<style lang="scss">

</style>
